package com.lovo.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.project.bean.JurisdictionBean;
import com.lovo.project.bean.RoleBean;
import com.lovo.project.mapper.JurisdictionMapper;
import com.lovo.project.mapper.RoleMapper;
import com.lovo.project.service.JurisdictionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JurisdictionServiceImpl extends ServiceImpl<JurisdictionMapper, JurisdictionBean> implements JurisdictionService {
   @Autowired
    JurisdictionMapper jurisdictionMapper;
   @Autowired
    RoleMapper roleMapper;
    @Override
    public List<RoleBean> queryJurisdictionList(List<Integer> roleId) {
        List<RoleBean> list=jurisdictionMapper.selectJurisdictionList(roleId);
        return list;
    }

    @Override
    public List<JurisdictionBean> selectJurisdictionList1(QueryWrapper queryWrapper) {
        List<JurisdictionBean> list=jurisdictionMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public void updateJurisdiction(Integer roleId, List<Integer> jurisdictionId) {
        jurisdictionMapper.deleteJurisdiction(roleId);
        jurisdictionMapper.insertJurisdiction(roleId,jurisdictionId);
    }

    @Override
    public void addRole(RoleBean roleBean, List<Integer> jurisdictionId) {
        roleMapper.insert(roleBean);
        jurisdictionMapper.insertJurisdiction(roleBean.getRoleId(),jurisdictionId);
    }
}
